package com.xjscrm.common.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 设备类型
 */
public enum DeviceTypeEnum {
    /**
     * PC个人微信
     */
    DT_PC_WECHAT(0,"private_wechat","PC个人微信", "个人微信用户"),

    /**
     * 安卓手机个人微信
     */
    DT_ANDROID_WECHAT(1,"private_wechat","安卓手机个人微信", "个人微信用户"),

    /**
     * PC企业微信
     */
    DT_WORK_WECHAT(2,"work_wechat","PC企业微信", "企业微信用户"),

    /**
     * Ipad协议个人微信
     */
    DT_IPAD_WECHAT(3,"private_wechat","Ipad协议个人微信", "个人微信用户"),

    /**
     * CMS
     */
    CMS(4,"cms","CMS", "CMS用户"),

    /**
     * 小程序
     */
    MINI_PRO(5,"mini_pro","小程序", "小程序用户"),

    /**
     * 公众号
     */
    WX_PUB(6,"wx_pub","公众号", "公众号用户"),

    /**
     * APP用户
     */
    APP(7, "app", "APP", "APP用户"),

    /**
     * 抖音设备
     */
    TIKTOK(8, "tiktok", "抖音", "抖音用户"),

    /**
     * 手机版企业微信
     */
    DT_ANDROID_WORK_WECHAT(9,"work_wechat","手机版企业微信", "手机版企业微信用户");

    public static final int DT_PC_WECHAT_VALUE = 0;
    public static final int DT_ANDROID_WECHAT_VALUE = 1;
    public static final int DT_WORK_WECHAT_VALUE = 2;
    public static final int DT_IPAD_WECHAT_VALUE = 3;
    public static final int CMS_VALUE = 4;
    public static final int MINI_PRO_VALUE = 5;
    public static final int WX_PUB_VALUE = 6;
    public static final int APP_VALUE = 7;
    public static final int TIKTOK_VALUE = 8;
    public static final int DT_ANDROID_WORK_WECHAT_VALUE = 9;

    private Integer id;
    private String key;
    private String desc;
    private String remark;
    DeviceTypeEnum(Integer id, String key, String desc, String remark) {
        this.id = id;
        this.key = key;
        this.desc = desc;
        this.remark = remark;
    }
    public Integer getId() {
        return id;
    }
    public String getKey() {
        return key;
    }
    public String getDesc() {
        return desc;
    }
    public String getRemark() {
        return remark;
    }
    public static DeviceTypeEnum getById(Integer id) {
        if (id == null) {
            return null;
        }
        for (DeviceTypeEnum type: DeviceTypeEnum.values()) {
            if (type.getId().intValue() == id) {
                return type;
            }
        }
        return null;
    }
    public static DeviceTypeEnum getByKey(String key) {
        if (StringUtils.isBlank(key)) {
            return null;
        }
        for (DeviceTypeEnum type: DeviceTypeEnum.values()) {
            if (type.getKey().equals(key)) {
                return type;
            }
        }
        return null;
    }
}
